﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace FoundationLib.Mail.Configuration
{
	/// <summary>
	/// This class represents a configuration section for mail connectors.
	/// </summary>
	public class MailConnectorConfigSection : ConfigurationSection
	{
		/// <summary>
		/// Creates a new <see cref="MailConnectorConfigSection"/>.
		/// </summary>
		public MailConnectorConfigSection()
			: base()
		{
		}

		/// <summary>
		/// Returns the mail connector settings from configuration.
		/// </summary>
		/// <returns>The mail connector settings</returns>
		public static MailConnectorConfigSection FromConfiguration()
		{
			return (ConfigurationManager.GetSection("mailConnectorConfiguration") as MailConnectorConfigSection);
		}

		/// <summary>
		/// Gets a value indicating whether debug mode is enabled.
		/// </summary>
		[ConfigurationProperty("debug", IsRequired = false, DefaultValue = false)]
		public bool Debug
		{
			get
			{
				return ((bool)this["debug"]);
			}
		}

		/// <summary>
		/// Gets the SMTP configuration element.
		/// </summary>
		[ConfigurationProperty("smtp")]
		public SmtpConfigElement Smtp
		{
			get
			{
				return (this["smtp"] as SmtpConfigElement);
			}
		}
	}
}
